<template>
  <div>
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/home' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>订单管理</el-breadcrumb-item>
      <el-breadcrumb-item>订单列表</el-breadcrumb-item>
    </el-breadcrumb>

    <el-card>
        <el-row>
            <el-col :span="8">
                  <el-input
        placeholder="请输入内容"
        v-model="querylist.query"
        class="input-with-select"
        clearable
        @clear="getorderlist"
      >
        <el-button
          slot="append"
          icon="el-icon-search"
          @click="getorderlist"
        ></el-button>
      </el-input>
            </el-col>
        </el-row>
    

      <el-table :data="oederlist" style="width: 100%" border>
        <el-table-column type="index" label="#"></el-table-column>
        <el-table-column label="订单编号" prop="order_number"></el-table-column>
        <el-table-column
          label="订单价格"
          prop="order_price"
          width="80px"
        ></el-table-column>
        <el-table-column label="是否付款" width="80px">
          <template slot-scope="scope">
            <el-tag type="danger" v-if="scope.row.pay_status === '0'"
              >未付款</el-tag
            >
            <el-tag type="success" v-else>已付款</el-tag>
          </template>
        </el-table-column>
        <el-table-column
          label="是否发货"
          prop="is_send"
          width="80px"
        ></el-table-column>
        <el-table-column label="下单时间" width="200px">
          <template slot-scope="scope">
            {{ scope.row.create_time | dateFormat }}
          </template>
        </el-table-column>
        <el-table-column label="操作" width="120px">
          <template slot-scope="scope">
            <el-button
              icon="el-icon-edit"
              type="primary"
              size="mini"
              @click="editDisgin"
            ></el-button>
            <el-button
              icon="el-icon-location"
              type="success"
              size="mini"
              @click="showProgress"
            ></el-button>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页器 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="querylist.pagenum"
        :page-sizes="[5, 10, 15, 20]"
        :page-size="querylist.pagesize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>

    <!-- 修改地址对话框 -->
    <el-dialog title="修改地址" :visible.sync="editdialogVisible" width="50%" @close="addressDialog">
      <el-form
        label-width="100px"
        :model="address"
        :rules="addressrules"
        ref="addressref"
      >
        <el-form-item label="省市区/县" prop="address1">
          <!-- 级联选择器 -->
          <el-cascader
            v-model="address.address1"
            :options="cityData"
            :props="{ expandTrigger: 'hover' }"
            @change="handleChange"
          ></el-cascader>
        </el-form-item>
        <el-form-item label="详细地址" prop="address2">
          <el-input v-model="address.address2"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="editdialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="editdialogVisible = false"
          >确 定</el-button
        >
      </span>
    </el-dialog>
    <!-- 查询物流的对话框 -->
    <el-dialog
  title="物流进度"
  :visible.sync="ProgressdialogVisible"
  width="50%">
  <span>这是一段信息</span>
</el-dialog>
  </div>
</template>

<script>
import uri from "../../config/uri";
import cityData from "../../assets/citydata";
export default {
  data() {
    return {
      oederlist: [],
      querylist: {
        query: "",
        pagenum: 1,
        pagesize: 10,
      },
      total: 0,
      // 修改对话框的显示与否
      editdialogVisible: false,
      //修改form的model
      address: {
        address1: [],
        address2: "",
      },
      //   修改的预验证
      addressrules: {
        address1: [
          {
            required: true,
            message: "请选择地区",
            trigger: "blur",
          },
        ],
        address2: [
          {
            required: true,
            message: "请输入详细地址",
            trigger: "blur",
          },
        ],
      },
      cityData: cityData,
    //   查询物流信息的对话框显示与否
      ProgressdialogVisible:false
    };
  },
  created() {
    this.getorderlist();
  },
  methods: {
    async getorderlist() {
      const res = await this.$http.get(uri.getorder, {
        params: this.querylist,
      });
      console.log(res);
      if (res.meta.status === 200) {
        this.oederlist = res.data.goods;
        this.total = res.data.total;
      } else {
        this.$message.error(res.meta.msg);
      }
    },
    handleSizeChange(newsize) {
      this.querylist.pagesize = newsize;
      this.getorderlist();
    },
    handleCurrentChange(newnum) {
      this.querylist.pagenum = newnum;
      this.getorderlist();
    },
    // 修改按钮
    editDisgin() {
      this.editdialogVisible = true;
    },
    // 级联选择器发生变化时，触发的函数
    handleChange(){

    },
    // 关闭修改对话框刷新其中的内容
    addressDialog(){
        this.$refs.addressref.resetFields()
    },
   async showProgress(){
       const res=await this.$http.get(uri.getorderid)
       console.log(res)
        this.ProgressdialogVisible=true
    }
  },
};
</script>

<style lang="less" scoped>
.el-table {
  margin-top: 10px;
  margin-bottom: 10px;
}
</style>
